/**
 *
 */
package com.mallsite.modules.shop.entity;

import javax.validation.Valid;

import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.JoinTable.Type;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.modules.sys.entity.User;

/**
 * <p>
 * TODO 描述
 * </p>
 *
 * @author ruyang
 * @since 2020年11月30日
 */
@Table(name="${_prefix}sys_user", alias="a", columns={
		@Column(includeEntity=User.class),
	}, joinTable={
		@JoinTable(type=Type.JOIN, entity=Member.class, alias="e",
			on="e.mem_code=a.ref_code AND a.user_type=#{USER_TYPE_MEMBER}"),
	},
	orderBy="a.user_weight DESC, a.update_date DESC"
)
public class MemUser extends User {
	
	private static final long serialVersionUID = 1L;
	
	public MemUser() {
		this(null);
	}

	public MemUser(String id){
		super(id);
	}
	
	@Valid
	public Member getMember(){
		Member member = (Member)super.getRefObj();
		if (member == null){
			member = new Member(getRefCode());
			super.setRefObj(member);
		}
		return member;
	}
	
	public void setMember(Member member){
		super.setRefObj(member);
	}
	
}
